<?php
use backend\assets\AgentAsset;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;

AgentAsset::register($this);
?>
<style>
	.addcard{position: relative;z-index: 10;border: 0;}
	.newcard{padding-top: 0!important;}
	.ok {position: relative;z-index: 11;}
	.rest{vertical-align: bottom;text-align: center;cursor: pointer;}
	.myclass{position: relative;  left: 50px; top: 5px;}
</style>
<div class="main" style="position: relative;padding-left: 40px;padding-right: 20px;">
	<div class="hide"><iframe name='send_post' id='send_post'></iframe></div>

	<div class="form-horizontal">
		<div class="clearfix mg20-y" >
			<label for="name" class="pull-left" style="height: 40px;line-height: 40px;">充值卡名称</label>
			<div class="radio-inline newcard" style="display:none;" >
				<?php ActiveForm::begin(['options'=>['target'=>'send_post','name'=>'register'],'action'=>Url::toRoute(['financial/cashier','action'=>'addbalancecard'])])?>
				<input class="mr20" id="title" type='text' name="title" style="height: 40px;line-height: 40px;vertical-align: top;" />
				<span class="btnBg" style="width: 45px; height: 40px;">
					<input type="submit" class="btn45" value="确定" style="height: 40px;line-height: 40px; background: 0; border: 0; "/>
				</span>
				<?php ActiveForm::end();?>
			</div>
			<button class="btnBg addcard pull-right"><i class="glyphicon glyphicon-plus-sign" style="margin-right:5px;"></i>添加新卡</button>
		</div>
		<div class="clearfix">
			<div class="" style="width: 390px; margin:0 auto;">
				<?php foreach($list as $r):?>
				<label class="radio-inline balancecard" style="margin-left:10px;">
					<input type="radio" name="id" id="inlineRadio1" value="<?=$r['config_id']?>">
					<?php ActiveForm::begin(['options'=>['target'=>'send_post'],'action'=>Url::toRoute(['financial/cashier','action'=>'updatebalancecard'])])?>
					<input type="hidden" name="config_id" value="<?=$r['config_id']?>" />
					<input type='text' name="title" readonly value='<?=$r['config_key']?>' />
					<input type="submit" class="btn45 ok" style="display:none; margin-top:-4px;" value="确定" />
					<?php ActiveForm::end();?>
				</label>
				<?php endforeach;?>
			</div>
		</div>

<!--	 <?php ActiveForm::begin(['options'=>['target'=>'send_post'],'action'=>Url::toRoute(['financial/cashier','action'=>'selectbalancecard'])])?>-->
	  <div class="group">
	    <label for="balance" class=" control-label " style="margin-right: 18px;padding-left: 14px;">充值金额</label>
		<input type="text" class="" value="0" data-rule="required;length" data-rule-length="[/^[0-9]\d*(\.\d+)?$/, '请输入大于0的数字']" id="balance" name="balance" style="width: 256px;height:34px;">
	  </div>
	  <div class="hide hide-param"></div>
	  <div class="mt20">
	    <label for="give_balance" class=" control-label" style="margin-right: 18px;padding-left: 14px;">赠送金额</label>
		<input type="text" class="" value="0" data-rule="required;length" data-rule-length="[/^[0-9]\d*(\.\d+)?$/, '请输入大于0的数字']" id="give_balance" name="give_balance" style="width: 256px;height:34px;">
	  </div>
	  <div class="mg20-y" style="text-align: center;">
		   <span class="btnBg" style="width: 92px; height: 32px;line-height: 32px;">
			  <input type="submit"onclick="checkparam()" value="确定"  style="display: inline-block; width: 100%; background: 0; border: 0 ;padding: 0" /></span>
		  <span class="btnBg bg_rest ml20" style="width: 92px; height: 32px;line-height: 32px;">
			 <input type="reset" value="取消" onclick="parent.closeWindow();"  class="rest" style="display: inline-block; width: 100%; background: 0; border: 0;padding: 0"/></span>
  	  </div>
  	  </div>
<!--  	  <?php ActiveForm::end()?>-->
</div>

<script>
	$('form[name="register"]').validator({
		focusCleanup: true,
		stopOnError:false,
//debug: true,
		timely: 2,
//自定义规则（PS：建议尽量在全局配置中定义规则，统一管理）
		rules: {
			length: [/^\S{0,5}$/, '请输入不超过5个字符的内容']
		},
		msgClass: "n-right myclass",
		fields: {
			'title': 'required; length;'
		}
	});
</script>
<?php $this->registerCssFile("@web/system/financial/cashier/index.css",['position'=>$this::POS_END]);?> 
<?php $this->registerJsFile("@web/system/financial/cashier/balancecard.js",['position'=>$this::POS_END]);?>